{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import re"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 任务 4 肥料产品的多维度对比分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>任务 4.1 设计算法或处理流程，从附件 4 技术指标中提取出氮、磷、钾养\n",
    "分和有机质的百分比，以及肥料含氯的程度。请在报告中给出处理思路及过程，\n",
    "并将结果保存到文件“result4_1.xlsx”中。</strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 读取数据\n",
    "data = pd.read_excel('./data/附件4.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py:5: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \"\"\"\n"
     ]
    }
   ],
   "source": [
    "# 将技术指标的数据全部转为字符串\n",
    "data['技术指标'] = data['技术指标'].apply(str)\n",
    "# 将技术指标数据的空格去除\n",
    "for i in range(len(data)):\n",
    "    data['技术指标'][i] = str(data['技术指标'][i]).replace(' ', '')\n",
    "# 筛选出有机肥料数据\n",
    "organic_data = data[data['产品通用名称'] == '有机肥料']\n",
    "# 筛选出复混肥料的数据\n",
    "mixing_data = data[data['产品通用名称']=='复混肥料']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "ename": "FileNotFoundError",
     "evalue": "[Errno 2] No such file or directory: './data/result4_1_data.xlsx'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-5-b47619280ad8>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mresult4_1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread_excel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'./data/result4_1_data.xlsx'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mresult4_1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\util\\_decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    175\u001b[0m                 \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    176\u001b[0m                     \u001b[0mkwargs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnew_arg_name\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnew_arg_value\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 177\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    178\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    179\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0m_deprecate_kwarg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\util\\_decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    175\u001b[0m                 \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    176\u001b[0m                     \u001b[0mkwargs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnew_arg_name\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnew_arg_value\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 177\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    178\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    179\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0m_deprecate_kwarg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\io\\excel.py\u001b[0m in \u001b[0;36mread_excel\u001b[1;34m(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, **kwds)\u001b[0m\n\u001b[0;32m    305\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    306\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mio\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mExcelFile\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 307\u001b[1;33m         \u001b[0mio\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mExcelFile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mio\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mengine\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mengine\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    308\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    309\u001b[0m     return io.parse(\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\pandas\\io\\excel.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, io, **kwds)\u001b[0m\n\u001b[0;32m    392\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbook\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxlrd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mopen_workbook\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfile_contents\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    393\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_io\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcompat\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstring_types\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 394\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbook\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mxlrd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mopen_workbook\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_io\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    395\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    396\u001b[0m             raise ValueError('Must explicitly set engine if not passing in'\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\xlrd\\__init__.py\u001b[0m in \u001b[0;36mopen_workbook\u001b[1;34m(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows)\u001b[0m\n\u001b[0;32m    114\u001b[0m         \u001b[0mpeek\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfile_contents\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mpeeksz\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    115\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 116\u001b[1;33m         \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"rb\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    117\u001b[0m             \u001b[0mpeek\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpeeksz\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    118\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mpeek\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34mb\"PK\\x03\\x04\"\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# a ZIP file\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: './data/result4_1_data.xlsx'"
     ]
    }
   ],
   "source": [
    "result4_1 = pd.read_excel('./data/result4_1_data.xlsx')\n",
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>有机质含量处理代码</strong>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理复混肥料的有机百分比，该百分比为0</strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 将复混肥料的有机质百分比全部置为 0\n",
    "for x in mixing_data['序号']:\n",
    "    result4_1.loc[result4_1['序号']==x,'有机质百分比'] = '0%'\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 将存在\"有机质≥\"字符串的技术指标的有机百分比取出\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('有机质≥' in data.loc[x]['技术指标']) == True:\n",
    "            # 查找“有机质≥”的位置\n",
    "            pos = data.loc[x]['技术指标'].find('有机质≥')\n",
    "            # num 为有机质的值\n",
    "            num = ''\n",
    "            strs = data.loc[x]['技术指标']\n",
    "            for y in range(pos+4,len(strs)):\n",
    "                if strs[y]=='%' or strs[y]=='％':\n",
    "                    num = num+'%'\n",
    "                    break\n",
    "                else:\n",
    "                    num = num+strs[y]\n",
    "            result4_1.loc[result4_1['序号']==i,'有机质百分比'] = num\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理氯相关数据<strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 处理含氯指标为0的情况\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('氯' in data.loc[x]['技术指标']) == False:\n",
    "        result4_1.loc[result4_1['序号']==i,'含氯情况'] = 0\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理 氮，磷，钾 的百分比</strong> N+P2O5+K2O≥51.0%（27-16-8）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 将存在\"N+P2O5+K2O≥\"字符串的技术指标的氮，磷，钾百分比计算出取出\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('N+P2O5+K2O≥' in data.loc[x]['技术指标']) == True:\n",
    "        # 查找“N+P2O5+K2O≥”的位置\n",
    "        pos = data.loc[x]['技术指标'].find('N+P2O5+K2O≥')\n",
    "        # num 为氮，磷，钾的值\n",
    "        num = ''\n",
    "        \n",
    "        # str为技术指标字符串\n",
    "        strs = data.loc[x]['技术指标']\n",
    "        \n",
    "        # 将总百分比解析出来\n",
    "        for y in range(pos+len('N+P2O5+K2O≥'),len(strs)):\n",
    "            if strs[y]=='%' or strs[y]=='％':\n",
    "                break\n",
    "            else:\n",
    "                num = num+strs[y]\n",
    "                \n",
    "        # 根据得到的总百分比来计算 氮，磷，钾 的情况          \n",
    "        num = float(num)    \n",
    "        num = round(num,2)\n",
    "        \n",
    "        # 定义正则表达式\n",
    "        p = re.compile('（[0-9][0-9]―[0-9][0-9]―[0-9][0-9]）')\n",
    "#         p1 = re.compile('（[0-9][0-9]-[0-9][0-9]-[0-9][0-9]）')\n",
    "        # 判断（10―18―15）这种配比在不在字符串\n",
    "        if (p.match(data.loc[x]['技术指标']))==True:\n",
    "            # 有配比，根据配比计算 氮，磷，钾\n",
    "            x = data.loc[x]['技术指标'].split('（')[1]\n",
    "            x = x.split(')')[1]\n",
    "            \n",
    "            N = x.split('―')[0]+'%'\n",
    "            P = x.split('―')[1]+'%'\n",
    "            K = x.split('―')[2]+'%'\n",
    "            \n",
    "            result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "            result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "            result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "#         elif (p1.match(data.loc[x]['技术指标'])) == True:\n",
    "#               # 有配比，根据配比计算 氮，磷，钾\n",
    "#             x = data.loc[x]['技术指标'].split('（')[1]\n",
    "#             x = x.split(')')[1]\n",
    "            \n",
    "#             N = x.split('―')[0]+'%'\n",
    "#             P = x.split('―')[1]+'%'\n",
    "#             K = x.split('―')[2]+'%'\n",
    "            \n",
    "#             result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "#             result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "#             result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "        else:\n",
    "            # 无配比，根据总百分比除以三\n",
    "            N = str(round(num/3,2))+'%'\n",
    "            P = str(round(num/3,2))+'%'\n",
    "            K = str(round(num/3,2))+'%'\n",
    "            result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "            result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "            result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "result4_1 = pd.read_excel('./result/result4_1.xlsx')\n",
    "data = pd.read_excel('./data/附件4.xlsx')\n",
    "NPK_data = result4_1[['总氮百分比','P2O5百分比','K2O百分比']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "result4_1 = pd.read_excel('./result/result4_1.xlsx')\n",
    "data = pd.read_excel('./data/附件4.xlsx')\n",
    "NPK_data = result4_1[['总氮百分比','P2O5百分比','K2O百分比']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>任务 4.1 设计算法或处理流程，从附件 4 技术指标中提取出氮、磷、钾养\n",
    "分和有机质的百分比，以及肥料含氯的程度。请在报告中给出处理思路及过程，\n",
    "并将结果保存到文件“result4_1.xlsx”中。</strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 读取数据\n",
    "data = pd.read_excel('./data/附件4.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda\\envs\\robots\\lib\\site-packages\\ipykernel_launcher.py:5: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \"\"\"\n"
     ]
    }
   ],
   "source": [
    "# 将技术指标的数据全部转为字符串\n",
    "data['技术指标'] = data['技术指标'].apply(str)\n",
    "# 将技术指标数据的空格去除\n",
    "for i in range(len(data)):\n",
    "    data['技术指标'][i] = str(data['技术指标'][i]).replace(' ', '')\n",
    "# 筛选出有机肥料数据\n",
    "organic_data = data[data['产品通用名称'] == '有机肥料']\n",
    "# 筛选出复混肥料的数据\n",
    "mixing_data = data[data['产品通用名称']=='复混肥料']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>产品通用名称</th>\n",
       "      <th>总氮百分比</th>\n",
       "      <th>P2O5百分比</th>\n",
       "      <th>K2O百分比</th>\n",
       "      <th>有机质百分比</th>\n",
       "      <th>含氯情况</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>196</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>197</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>198</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>199</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>200</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      序号     产品通用名称  总氮百分比  P2O5百分比  K2O百分比  有机质百分比  含氯情况\n",
       "0      1       复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "1      2       复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "2      3       有机肥料    NaN      NaN     NaN     NaN   NaN\n",
       "3      4       复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "4      5       有机肥料    NaN      NaN     NaN     NaN   NaN\n",
       "..   ...        ...    ...      ...     ...     ...   ...\n",
       "195  196  有机-无机复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "196  197  有机-无机复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "197  198       有机肥料    NaN      NaN     NaN     NaN   NaN\n",
       "198  199       有机肥料    NaN      NaN     NaN     NaN   NaN\n",
       "199  200  有机-无机复混肥料    NaN      NaN     NaN     NaN   NaN\n",
       "\n",
       "[200 rows x 7 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result4_1 = pd.read_excel('./data/result4_1_data.xlsx')\n",
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>有机质含量处理代码</strong>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理复混肥料的有机百分比，该百分比为0</strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将复混肥料的有机质百分比全部置为 0\n",
    "for x in mixing_data['序号']:\n",
    "    result4_1.loc[result4_1['序号']==x,'有机质百分比'] = '0%'\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将存在\"有机质≥\"字符串的技术指标的有机百分比取出\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('有机质≥' in data.loc[x]['技术指标']) == True:\n",
    "            # 查找“有机质≥”的位置\n",
    "            pos = data.loc[x]['技术指标'].find('有机质≥')\n",
    "            # num 为有机质的值\n",
    "            num = ''\n",
    "            strs = data.loc[x]['技术指标']\n",
    "            for y in range(pos+4,len(strs)):\n",
    "                if strs[y]=='%' or strs[y]=='％':\n",
    "                    num = num+'%'\n",
    "                    break\n",
    "                else:\n",
    "                    num = num+strs[y]\n",
    "            result4_1.loc[result4_1['序号']==i,'有机质百分比'] = num\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>产品通用名称</th>\n",
       "      <th>总氮百分比</th>\n",
       "      <th>P2O5百分比</th>\n",
       "      <th>K2O百分比</th>\n",
       "      <th>有机质百分比</th>\n",
       "      <th>含氯情况</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>196</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>197</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>198</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>199</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>200</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      序号     产品通用名称  总氮百分比  P2O5百分比  K2O百分比 有机质百分比  含氯情况\n",
       "0      1       复混肥料    NaN      NaN     NaN     0%   NaN\n",
       "1      2       复混肥料    NaN      NaN     NaN     0%   NaN\n",
       "2      3       有机肥料    NaN      NaN     NaN    45%   NaN\n",
       "3      4       复混肥料    NaN      NaN     NaN     0%   NaN\n",
       "4      5       有机肥料    NaN      NaN     NaN    45%   NaN\n",
       "..   ...        ...    ...      ...     ...    ...   ...\n",
       "195  196  有机-无机复混肥料    NaN      NaN     NaN    20%   NaN\n",
       "196  197  有机-无机复混肥料    NaN      NaN     NaN    20%   NaN\n",
       "197  198       有机肥料    NaN      NaN     NaN    45%   NaN\n",
       "198  199       有机肥料    NaN      NaN     NaN    45%   NaN\n",
       "199  200  有机-无机复混肥料    NaN      NaN     NaN    15%   NaN\n",
       "\n",
       "[200 rows x 7 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理氯相关数据<strong>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 处理含氯指标为0的情况\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('氯' in data.loc[x]['技术指标']) == False:\n",
    "        result4_1.loc[result4_1['序号']==i,'含氯情况'] = 0\n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>产品通用名称</th>\n",
       "      <th>总氮百分比</th>\n",
       "      <th>P2O5百分比</th>\n",
       "      <th>K2O百分比</th>\n",
       "      <th>有机质百分比</th>\n",
       "      <th>含氯情况</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>196</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>197</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>198</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>199</td>\n",
       "      <td>有机肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45%</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>200</td>\n",
       "      <td>有机-无机复混肥料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15%</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      序号     产品通用名称  总氮百分比  P2O5百分比  K2O百分比 有机质百分比  含氯情况\n",
       "0      1       复混肥料    NaN      NaN     NaN     0%   0.0\n",
       "1      2       复混肥料    NaN      NaN     NaN     0%   NaN\n",
       "2      3       有机肥料    NaN      NaN     NaN    45%   0.0\n",
       "3      4       复混肥料    NaN      NaN     NaN     0%   NaN\n",
       "4      5       有机肥料    NaN      NaN     NaN    45%   0.0\n",
       "..   ...        ...    ...      ...     ...    ...   ...\n",
       "195  196  有机-无机复混肥料    NaN      NaN     NaN    20%   NaN\n",
       "196  197  有机-无机复混肥料    NaN      NaN     NaN    20%   NaN\n",
       "197  198       有机肥料    NaN      NaN     NaN    45%   0.0\n",
       "198  199       有机肥料    NaN      NaN     NaN    45%   0.0\n",
       "199  200  有机-无机复混肥料    NaN      NaN     NaN    15%   NaN\n",
       "\n",
       "[200 rows x 7 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result4_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<strong>处理 氮，磷，钾 的百分比</strong> N+P2O5+K2O≥51.0%（27-16-8）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将存在\"N+P2O5+K2O≥\"字符串的技术指标的氮，磷，钾百分比计算出取出\n",
    "for x in list(data.index):\n",
    "    i = data.loc[x]['序号']\n",
    "    if ('N+P2O5+K2O≥' in data.loc[x]['技术指标']) == True:\n",
    "        # 查找“N+P2O5+K2O≥”的位置\n",
    "        pos = data.loc[x]['技术指标'].find('N+P2O5+K2O≥')\n",
    "        # num 为氮，磷，钾的值\n",
    "        num = ''\n",
    "        \n",
    "        # str为技术指标字符串\n",
    "        strs = data.loc[x]['技术指标']\n",
    "        \n",
    "        # 将总百分比解析出来\n",
    "        for y in range(pos+len('N+P2O5+K2O≥'),len(strs)):\n",
    "            if strs[y]=='%' or strs[y]=='％':\n",
    "                break\n",
    "            else:\n",
    "                num = num+strs[y]\n",
    "                \n",
    "        # 根据得到的总百分比来计算 氮，磷，钾 的情况          \n",
    "        num = float(num)    \n",
    "        num = round(num,2)\n",
    "        \n",
    "        # 定义正则表达式\n",
    "        p = re.compile('（[0-9][0-9]―[0-9][0-9]―[0-9][0-9]）')\n",
    "#         p1 = re.compile('（[0-9][0-9]-[0-9][0-9]-[0-9][0-9]）')\n",
    "        # 判断（10―18―15）这种配比在不在字符串\n",
    "        if (p.match(data.loc[x]['技术指标']))==True:\n",
    "            # 有配比，根据配比计算 氮，磷，钾\n",
    "            x = data.loc[x]['技术指标'].split('（')[1]\n",
    "            x = x.split(')')[1]\n",
    "            \n",
    "            N = x.split('―')[0]+'%'\n",
    "            P = x.split('―')[1]+'%'\n",
    "            K = x.split('―')[2]+'%'\n",
    "            \n",
    "            result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "            result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "            result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "#         elif (p1.match(data.loc[x]['技术指标'])) == True:\n",
    "#               # 有配比，根据配比计算 氮，磷，钾\n",
    "#             x = data.loc[x]['技术指标'].split('（')[1]\n",
    "#             x = x.split(')')[1]\n",
    "            \n",
    "#             N = x.split('―')[0]+'%'\n",
    "#             P = x.split('―')[1]+'%'\n",
    "#             K = x.split('―')[2]+'%'\n",
    "            \n",
    "#             result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "#             result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "#             result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "        else:\n",
    "            # 无配比，根据总百分比除以三\n",
    "            N = str(round(num/3,2))+'%'\n",
    "            P = str(round(num/3,2))+'%'\n",
    "            K = str(round(num/3,2))+'%'\n",
    "            result4_1.loc[result4_1['序号']==i,'总氮百分比'] = N\n",
    "            result4_1.loc[result4_1['序号']==i,'P2O5百分比'] = P\n",
    "            result4_1.loc[result4_1['序号']==i,'K2O百分比'] = K    \n",
    "result4_1.to_excel('./result/result4_1.xlsx',encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "result4_1 = pd.read_excel('./result/result4_1.xlsx')\n",
    "data = pd.read_excel('./data/附件4.xlsx')\n",
    "NPK_data = result4_1[['总氮百分比','P2O5百分比','K2O百分比']]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
